home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / utility.lha / utility / listiter.C < prev    next >
C/C++ Source or Header  |  1993-08-08  |  659b  |  32 lines

  1. // Generic list iterator (implementation module).
  2. //
  3. // It is a good idea to have an index into the pointer array, rather
  4. // than a pointer.  If some fool inserts an element while iterating
  5. // over the list, the pointer array may be reallocated.  The index
  6. // version still works.
  7. //
  8. // Author:
  9. //
  10. // Dag Bruck, Department of Automatic Control, Lund Institute of Technology,
  11. // Box 118, S-221 00 Lund, Sweden (dag@control.lth.se).
  12. //
  13. // $Id: listiter.C,v 1.3 91/09/06 17:03:42 dag Exp $
  14.  
  15.  
  16. #include <listiter.H>
  17.  
  18.  
  19. void GenericIterator :: Rewind()
  20. {
  21.   i = 0;
  22. }
  23.  
  24.  
  25. void GenericIterator :: Skip(int di)
  26. {
  27.   if (di + int(i) < 0)
  28.     Rewind();
  29.   else
  30.     i += di;
  31. }
  32.